import java.util.ArrayList;
import java.util.List;

public class StudentDome1 {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();

        list.add(new Student("张三","男",23));
        list.add(new Student("李四","男",28));
        list.add(new Student("王五","男",24));

        int max = 0;//最大年龄
        int b = -1;//代表最大年龄的索引
        for (int i = 0; i < list.size(); i++) {

            if (list.get(i).getAge()>max){
                max=list.get(i).getAge();
                b=i;
            }

        }
        if (b!=-1){
            list.get(b).setName("小猪佩奇");

        }

        for (Student student : list) {
            System.out.println(student);
        }

    }

}
